package com.sendpo.zjx.sendpo.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.sendpo.zjx.sendpo.R;
import com.sendpo.zjx.sendpo.utils.Tools;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by 朱俊鑫 on 2018
 */

public class MyselfFabuListAddTitleActivity extends AppCompatActivity {

    @BindView(R.id.backbt)
    RelativeLayout backbt;
    @BindView(R.id.index_head)
    RelativeLayout indexHead;
    @BindView(R.id.listview)
    ListView listview;
    private ListApdater apdater;
    public static final String[] strs = { "100人", "300人", "500人", "1000人", "一起狂欢", "靓女靓仔", "机会难得", "一起哈皮", "免费", "收费" };
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_myselffabulist_addtitle);
        ButterKnife.bind(this);
        Tools.initStatus(this, R.color.black);
        initComponent();

    }

    private void initComponent() {


        listview.setAdapter(new ListApdater());
        this.listview.setOnItemClickListener(new AdapterView.OnItemClickListener()
        {
            public void onItemClick(AdapterView<?> paramAnonymousAdapterView, View paramAnonymousView, int paramAnonymousInt, long paramAnonymousLong)
            {
             Intent intent = new Intent();
                intent.putExtra("data", strs[paramAnonymousInt]);
              setResult(RESULT_OK,intent);
              finish();
            }
        });
    }
     @OnClick(value = {R.id.backbt})
     public void onMyClick(View view){
        switch (view.getId()){
            case R.id.backbt:
                finish();
                break;
        }
     }

     public class ListApdater extends BaseAdapter{

         @Override
         public int getCount() {
             return MyselfFabuListAddTitleActivity.strs.length;
         }

         @Override
         public Object getItem(int position) {
             return MyselfFabuListAddTitleActivity.strs[position];
         }

         @Override
         public long getItemId(int position) {
             return position;
         }

         @Override
         public View getView(int position, View convertView, ViewGroup parent) {
             if(convertView==null){
                 convertView =View.inflate(MyselfFabuListAddTitleActivity.this,R.layout.layout_storecategory,null);
                 ((TextView)convertView.findViewById(R.id.name_tv)).setText(MyselfFabuListAddTitleActivity.strs[position]);
                 return convertView;
             }else{
                 ((TextView)convertView.findViewById(R.id.name_tv)).setText(MyselfFabuListAddTitleActivity.strs[position]);
                 return convertView;
             }
         }
     }


}
